﻿@inherits AdminCompontentBase
<div class="status-time-line">
    <MTimeline Dense=false>
        @foreach (var item in _statusCommits)
        {
            <MTimelineItem Color="fill" Small FillDot Right Class="align-center">
                <OppositeContent>
                    <div class="@($"btn mr-n7 {GetStatusColor(item.Status)}")">@T(item.Status.ToString())</div>
                </OppositeContent>
                <IconContent>
                    <AlarmHistoryStatusIcon Value="@item.Status" />
                </IconContent>
                <ChildContent>
                    <div class="ml-n5">
                        <div class="regular--text btn">@item.Remarks</div>
                        <div class="regular3--text overline">@item.CreationTime.ToOffset(JsInitVariables.TimezoneOffset).ToString(T("$DateTimeFormat"))</div>
                    </div>
                </ChildContent>
            </MTimelineItem>
        }
    </MTimeline>
</div>

@code {
    [Parameter]
    public List<AlarmHandleStatusCommitViewModel> StatusCommits { get; set; } = new();

    private List<AlarmHandleStatusCommitViewModel> _statusCommits => StatusCommits.OrderByDescending(x => x.CreationTime).ToList();

    private string _class = string.Empty;

    private string GetStatusColor(AlarmHistoryHandleStatuses Status)
    {
        switch (Status)
        {
            case AlarmHistoryHandleStatuses.Notified:
                return "info--text";
            case AlarmHistoryHandleStatuses.ProcessingCompleted:
                return "success--text";
            case AlarmHistoryHandleStatuses.InProcess:
                return "primary--text";
            case AlarmHistoryHandleStatuses.Pending:
                return "remind--text";
            default:
                return "";
        }
    }
}
